home *** CD-ROM | disk | FTP | other *** search
/ PD Collection CD 1 / PD Collection CD 1.iso / textual / tex / files / !preview / RCS / c / routines < prev    next >
Encoding:
Text File  |  1990-07-09  |  1.5 KB  |  128 lines

  1. head     1.2;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    gtoal:1.2;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.2
  10. date     91.03.02.13.59.24;  author gtoal;  state Exp;
  11. branches ;
  12. next     1.1;
  13.  
  14. 1.1
  15. date     91.03.02.13.56.10;  author gtoal;  state Exp;
  16. branches ;
  17. next     ;
  18.  
  19.  
  20. desc
  21. @Initial release
  22. @
  23.  
  24.  
  25. 1.2
  26. log
  27. @IAY's upgrade
  28. @
  29. text
  30. @/* c.routines --- auxilary routines.  */
  31.  
  32. #include <stdarg.h>
  33. #include <stdlib.h>
  34. #include <stdio.h>
  35. #include "d2rd.h"
  36. #include "kernel.h"
  37.  
  38. int
  39. fatal (const char *fmt, ...)
  40. {
  41.   va_list ap;
  42.   static struct
  43.    {
  44.      int dummy;
  45.      char msg[2048];
  46.    } msg;
  47.  
  48.   va_start (ap, fmt);
  49.   vsprintf (msg.msg, fmt, ap);
  50.   va_end (ap);
  51.  
  52.   wimp_reporterror ((os_error *) &msg, wimp_EHICANCEL, PROGRAM_NAME);
  53.  
  54.   return (-1);
  55. }
  56.  
  57.  
  58. void
  59. tfatal (const char *fmt, ...)
  60. {
  61.   va_list ap;
  62.   static struct
  63.    {
  64.      int dummy;
  65.      char msg[2048];
  66.    } msg;
  67.  
  68.   va_start (ap, fmt);
  69.   vsprintf (msg.msg, fmt, ap);
  70.   va_end (ap);
  71.  
  72.   wimp_reporterror ((os_error *) &msg, wimp_EHICANCEL, PROGRAM_NAME);
  73.   exit (1);
  74. }
  75.  
  76.  
  77. void *
  78. xmalloc (int i)
  79. {
  80.   void *r = malloc (i ? i : 1);
  81.  
  82.   if (r == NULL)
  83.     {
  84.       tfatal ("Out of VM\n");
  85.       abort ();
  86.     }
  87.   return (r);
  88. }
  89.   
  90.  
  91. void *
  92. xcalloc (int i, int j)
  93. {
  94.   void *r = calloc (i, j);
  95.  
  96.   if (r == NULL)
  97.     {
  98.       tfatal ("Out of VM\n");
  99.       abort ();
  100.     }
  101.   return (r);
  102. }
  103.   
  104.  
  105. void *
  106. xrealloc (void *i, int j)
  107. {
  108.   void *r = realloc (i, j);
  109.  
  110.   if (r == NULL && j != 0)
  111.     {
  112.       tfatal ("Out of VM\n");
  113.       abort ();
  114.     }
  115.   return (r);
  116. }
  117.  
  118. /* EOF */
  119. @
  120.  
  121.  
  122. 1.1
  123. log
  124. @Initial revision
  125. @
  126. text
  127. @@
  128.